<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property int $corp_id 企业ID
 * @property int $robot_id 企微号ID
 * @property int $status 状态：0=等待中 1=进行中 2=同步成功 3=同步失败
 * @property int $type 类型：1=企业标签 2=个人标签
 * @property string $failure_reason 失败原因
 * @property int $start_time 开始时间
 * @property int $end_time 结束时间
 * @property array $extra 额外参数
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property-read null|ChRobot $robot 
 */
class ChSyncTask extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_sync_task';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'corp_id', 'robot_id', 'status', 'type', 'failure_reason', 'start_time', 'end_time', 'extra', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'corp_id' => 'integer', 'robot_id' => 'integer', 'status' => 'integer', 'type' => 'integer', 'start_time' => 'integer', 'end_time' => 'integer', 'extra' => 'array', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function robot(): HasOne
    {
        return $this->hasOne(ChRobot::class,'id','robot_id');
    }
}
